import logging
import allure,time
import pytest
from data.constant import *
from base.base_analyze import analyze_data

@allure.feature('网校运营中心/产品管理')  # 所属模块
class TestCase02rganizationMgt(object):
    """
    BLOCKER = 'blocker'  阻塞的
    CRITICAL = 'critical'  危险的
    NORMAL = 'normal'  正常的
    MINOR = 'minor'  次要的
    TRIVIAL = 'trivial' 不重要的
    """
    @allure.severity(severity_level="normal")  # 严重级别
    @allure.story("TestCase72OrganizationMgt001_【基线用例】后台/产品管理：批量上架产品：新建产品")# 用例标题
    @allure.testcase("https://chandao.mshiedu.com/zentao/testcase-view-30618-1.html", "【基线用例】后台/产品管理：新建产品")# 禅道链接
    # @pytest.mark.parametrize("login_hjx",[],indirect = True)
    def testCase02rganizationMgt001(self,login_hjx):
        logging.info('开始执行测试用例====》')
        login_hjx.pageProductList.click_product_control()   # 点击切换产品管理菜单
        time.sleep(2)
        login_hjx.pageProductList.click_switch_to()  # 切换iframe
        time.sleep(2)
        login_hjx.pageProductList.click_new_construction()  # 点击新建
        time.sleep(2)
        login_hjx.pageProductList.create_product()  # 创建产品
        time.sleep(2)
        assert "课程计划" in login_hjx.pageProductList.get_curriculum_plan(), "用例成功"


    @allure.severity(severity_level="normal")  # 严重级别
    @allure.story("TestCase72OrganizationMgt001_【基线用例】后台/产品管理：批量上架产品")# 用例标题
    @allure.testcase("暂无禅道用例")# 禅道链接
    # @pytest.mark.parametrize("login_hjx",[],indirect = True)
    def testCase02ShelfProduct002(self,login_hjx):
        logging.info('开始执行测试用例====》')
        login_hjx.pageProductList.click_product_control()   # 点击切换产品管理菜单
        time.sleep(2)
        login_hjx.pageProductList.click_switch_to()  # 切换iframe
        time.sleep(2)
        login_hjx.pageProductList.click_shelf_bulk()    # 批量上架产品流程
        assert "批量上架成功" in login_hjx.pageProductList.get_shelf_success(), "用例成功"



    @allure.severity(severity_level="normal")  # 严重级别
    @allure.story("TestCase72OrganizationMgt001_【基线用例】后台/产品管理：批量上架产品")# 用例标题
    @allure.testcase("暂无禅道用例")# 禅道链接
    # @pytest.mark.parametrize("login_hjx",[],indirect = True)
    def testCase02RemoveProduct003(self,login_hjx):
        logging.info('开始执行测试用例====》')
        login_hjx.pageProductList.click_product_control()   # 点击切换产品管理菜单
        time.sleep(2)
        login_hjx.pageProductList.click_switch_to()  # 切换iframe
        time.sleep(2)
        login_hjx.pageProductList.click_removed_product()    # 批量上架产品流程
        assert "批量下架成功" in login_hjx.pageProductList.get_removed_successfully(), "用例成功"


    @allure.severity(severity_level="normal")  # 严重级别
    @allure.story("TestCase72OrganizationMgt001_【基线用例】后台/产品管理：成功编辑自建产品")# 用例标题
    @allure.testcase("暂无禅道用例")# 禅道链接
    # @pytest.mark.parametrize("login_hjx",[],indirect = True)
    def testCase02RemoveProduct004(self,login_hjx):
        logging.info('开始执行测试用例====》')
        login_hjx.pageProductList.click_product_control()   # 点击切换产品管理菜单
        time.sleep(2)
        login_hjx.pageProductList.click_switch_to()  # 切换iframe
        time.sleep(2)
        login_hjx.pageProductList.click_search_product()    # 点击查询并编辑产品
        login_hjx.pageProductList.click_editor_produc(input_box='服务周期', service_period=SERVICE_PERIOD, standard_price=STANDARD_PRICE, minprice=MINPRICE)  # 输入服务周期
        time.sleep(1)
        login_hjx.pageProductList.click_editor_produc(input_box='标准收费', service_period=SERVICE_PERIOD, standard_price=STANDARD_PRICE, minprice=MINPRICE)  # 输入标准收费
        time.sleep(1)
        login_hjx.pageProductList.click_editor_produc(input_box='最低价格', service_period=SERVICE_PERIOD, standard_price=STANDARD_PRICE, minprice=MINPRICE)  # 输入最低价格
        time.sleep(1)
        login_hjx.pageProductList.click_editor_save()    # 点击保存
        time.sleep(1)
        assert "提交成功" in login_hjx.pageProductList.get_save_successfully1(), "用例成功"
        login_hjx.pageProductList.click_editor_cancel()  # 取消返回列表页